<?php

class Events{
	private $events = array();
	
	function addHandler($type, $callback, &$obj = false)
	{
		if (!isset($this->events[$type]))
			$this->events[$type] = array();
		$this->events[$type][] = array(
			"func" => $callback,
			"instance" => $obj
		);
	}
	
	
	function fireEvent($type)
	{
		if (isset($this->events[$type])){
			$args = func_get_args();
			$res = array();
			foreach ($this->events[$type] as $callback){
				if (!$callback['instance']){
					$res[] = call_user_func_array($callback['func'], array_slice($args, 1));
				} elseif (is_string($callback['instance'])){
					
				} elseif ($callback['instance']){
					
				}
			}
			return $res;
		}
		return array();
	}
	
}
?>